package com.evan.wj.dao;

import com.evan.wj.pojo.Book;
import com.evan.wj.pojo.Category;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

public interface BookDAO extends JpaRepository<Book, Integer>, JpaSpecificationExecutor<Book> {
    List<Book> findAllByCategory(Category category);
/*    List<Book> findByCategoryOrCategory(Category category1,Category category2);*/
    List<Book> findAllByTitleLikeOrAuthorLike(String keyword1, String keyword2);

    //通过Specification对查询数据进行筛选，返回筛选后的所有数据
    List<Book> findAll(Specification<Book> var1);

/*    //分页查询，Specification可对查询数据进行筛选
    Page<Book> findAll(@Nullable Specification<Book> var1, Pageable var2);

    //通过Specification对查询数据进行筛选，返回筛选后的所有数据根据Sort排序
    List<Book> findAll(@Nullable Specification<Book> var1, Sort var2);*/
}
